/**
 * DataSetBean.java : [com.shift.converter.editors.beans] Created on 2009. 5. 5.
 * 
 * Copyright (c) 2000-2008 Shift Information & Communication Co.
 * 5F, Seongsu Venture town, 231-1, Seongsu2-Ga Seongdong-Gu, Seoul, Korea 133-826
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Shift Information & Communication Co. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use 
 * it only in accordance with the terms of the license agreement you 
 * entered into with Shift Information & Communication.
 */
package com.shift.converter.beans;

import java.util.ArrayList;
import java.util.List;

public class DataSetBean {
	public static final String NAME_CHANGED = "DATASET_NAME_CHANGED";

	public static final String XPATH_CHANGED = "DATASET_XPATH_CHANGED";

	public static final String URL_CHANGED = "DATASET_URL_CHANGED";
	
	public static final String COLUMN_ADD = "DATASET_COLUMN_ADD";
	
	public static final String COLUMN_REMOVE = "DATASET_COLUMN_REMOVE";
	
	private String name = "";
	
	private String xpath = "";
	
	private String url = "";
	
	private List columnList = new ArrayList();
	
	private MapConfigBean mapConfigBean;
	
	public DataSetBean() {
		mapConfigBean = new MapConfigBean();
	}
	
	public DataSetBean(MapConfigBean mapConfigBean) {
		this.mapConfigBean = mapConfigBean;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String oldValue = this.name;
		this.name = name;
		mapConfigBean.firePropertyChange(NAME_CHANGED, oldValue, this);
	}

	public String getXpath() {
		return xpath;
	}

	public void setXpath(String xpath) {
		String oldValue = this.xpath;
		this.xpath = xpath;
		mapConfigBean.firePropertyChange(XPATH_CHANGED, oldValue, this);
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		String oldValue = this.url;
		this.url = url;
		mapConfigBean.firePropertyChange(URL_CHANGED, oldValue, this);
	}
	
	public void addColumn(DataSetColumnBean column) {
		this.columnList.add(column);
		mapConfigBean.firePropertyChange(COLUMN_ADD, null, column);
	}
	
	public void removeColumn(DataSetColumnBean column) {
		this.columnList.remove(column);
		mapConfigBean.firePropertyChange(COLUMN_REMOVE, column, null);
	}
	
	public DataSetColumnBean[] getColumnList() {
		return (DataSetColumnBean[]) columnList.toArray(new DataSetColumnBean[0]);
	}
}
